<div class="text-lg font-medium mb-4"> {{ 'COMPONENTS.CALCULATION.ConditionalAggregation' | translate: {Default: "Conditional Aggregation"} }} </div>

<form [formGroup]="formGroup" class="flex flex-col justify-start items-stretch" displayDensity="cosy">
  <div class="flex items-start gap-4">
    <ngm-select class="ngm-calculation__form-field" [label]="'COMPONENTS.CALCULATION.OPERATION' | translate: {Default: 'Operation'}"
      formControlName="operation"
      [selectOptions]="OPERATIONS"
    ></ngm-select>

    <ngm-parameter-select *ngIf="formGroup.value.operation === AggregationOperation.TOP_PERCENT || formGroup.value.operation === AggregationOperation.TOP_COUNT"
      class="flex-1"
      [label]=" 'COMPONENTS.CALCULATION.VALUE' | translate: {Default: 'Value'} "
      [dataSettings]="dataSettings"
      [entityType]="entityType"
      formControlName="value"
    >
    </ngm-parameter-select>

  </div>

  <!-- <ngm-select class="pt-4" formControlName="measure" label="{{ 'COMPONENTS.CALCULATION.Measure' | translate: {Default: 'Measure'} }}"
    formControlName="measure"
    [selectOptions]="measures$()"
  ></ngm-select> -->

  <ngm-measure-select1 class="pt-4" formControlName="measure" label="{{ 'COMPONENTS.CALCULATION.Measure' | translate: {Default: 'Measure'} }}"
    [dataSettings]="dataSettings"
    [filter]="filterMeasure"
  />

  <div class="text-base my-4">{{ 'COMPONENTS.CALCULATION.AGGREGATION_DIMENSIONS' | translate: {Default: "Aggregation Dimensions"} }}</div>
  <ngm-property-array class="ngm-conditional-aggregation__dimensions"
    formControlName="aggregationDimensions"
    [dataSettings]="dataSettings"
    [entityType]="entityType"
    [capacities]="[PropertyCapacity.Dimension]"
  ></ngm-property-array>

  <mat-checkbox formControlName="useConditionalAggregation" class="my-2">
    {{ 'COMPONENTS.CALCULATION.UseConditionalAggregation' | translate: {Default: "Use Conditional Aggregation"} }}
  </mat-checkbox>

  <div *ngIf="formGroup.value.useConditionalAggregation" class="ngm-conditional-aggregation__conditions flex flex-col justify-start items-stretch">
    <div class="ngm-calculation__form-row">
        <mat-checkbox formControlName="excludeConditions">
          {{ 'COMPONENTS.CALCULATION.ExcludeConditions' | translate: {Default: "Exclude Conditions"} }}
        </mat-checkbox>
    </div>

    <div class="text-base my-4">
      {{ 'COMPONENTS.CALCULATION.ConditionalDimensions' | translate: {Default: "Conditional Dimensions"} }}
    </div>
    <ngm-property-array class="w-full"
      formControlName="conditionalDimensions"
      [dataSettings]="dataSettings"
      [entityType]="entityType"
      [coreService]="coreService"
      [dsCoreService]="dsCoreService"
      [capacities]="[PropertyCapacity.Dimension]"
    ></ngm-property-array>

  </div>
    
</form>
